﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public enum BulletState
{
    IDLE,
    FLAYING,
}

public enum Android_Kind
{
    EASY,
    NORMAL,
    HARD
}
public class MyEventListener<T>
{
    public delegate void OnValueChangeDelegate(T newValue);
    public event OnValueChangeDelegate OnValueChange;
    private T m_value;
    public T Value
    {
        get
        {
            return m_value;
        }
        set
        {
            if (m_value.Equals(value)) return;
            OnValueChange?.Invoke(value);
            m_value = value;
        }
    }
}
public class GameRunningData
{
    private GameRunningData() { }
    private static GameRunningData gameRunningData;
    public static GameRunningData Instance
    {
        get
        {
            if (gameRunningData == null)
            {
                gameRunningData = new GameRunningData();
            }
            return gameRunningData;
        }
    }
    private MyEventListener<float> hpListener;


}


class AndroidInfo
{
    float blood;
    float force;
    float speed;
    float rebloodTime;
    float shotSpeed;
    
    public AndroidInfo(float blood, float force, float speed, float rebloodTime, float shotSpeed)
    {
        this.Blood = blood;
        this.Force = force;
        this.Speed = speed;
        this.RebloodTime = rebloodTime;
        this.ShotSpeed = shotSpeed;
    }

    public float Blood { get => blood; set => blood = value; }
    public float Force { get => force; set => force = value; }
    public float Speed { get => speed; set => speed = value; }
    public float RebloodTime { get => rebloodTime; set => rebloodTime = value; }
    public float ShotSpeed { get => shotSpeed; set => shotSpeed = value; }
}

class PlayerInfo
{
    float blood;
    float force;
    float speed;
    float rebloodTime;
    float shotSpeed;

    public PlayerInfo(float blood, float force, float speed, float rebloodTime, float shotSpeed)
    {
        this.Blood = blood;
        this.Force = force;
        this.Speed = speed;
        this.RebloodTime = rebloodTime;
        this.ShotSpeed = shotSpeed;
    }

    public float Blood { get => blood; set => blood = value; }
    public float Force { get => force; set => force = value; }
    public float Speed { get => speed; set => speed = value; }
    public float RebloodTime { get => rebloodTime; set => rebloodTime = value; }
    public float ShotSpeed { get => shotSpeed; set => shotSpeed = value; }
}

public class GameInfo 
{
    /// <summary>
    /// 血量变化事件
    /// </summary>
    /// <param name="hp"></param>
    public delegate void HpChange(float hp);
    public HpChange onHpChange;

    /// <summary>
    /// 敌人数量变化事件
    /// </summary>
    /// <param name="e"></param>
    public delegate void EnemyChange(int e);
    public EnemyChange onEnemyChange;

    /// <summary>
    /// 单例
    /// </summary>
    private GameInfo() { }
    private static GameInfo gameInfo;
    public static GameInfo Instance {
        get {
            if (gameInfo==null)
            {
                gameInfo = new GameInfo();
            }
            return gameInfo;
        }
    }
    public void Restart()
    {
        gameInfo = null;
    }
    /// <summary>
    /// 玩家当前位置
    /// </summary>
    private Vector3 playerPos= Vector3.zero;
    public Vector3 GetPlayerPos()
    {
        return playerPos;
    }
    public void SetPlayerPos(Vector3 pos)
    {
        playerPos = pos;
    }

    /// <summary>
    /// 机器人的目标
    /// </summary>
    private Transform androidAim=null;
    public void SetAndroidAim(Transform tra)
    {
        androidAim = tra;
    }
    public Transform GetAndroidAim()
    {
        return androidAim;
    }

    /// <summary>
    /// 玩家子弹的对象池
    /// </summary>
    public Queue<Transform> PlayerBulletPool = new Queue<Transform>();

    /// <summary>
    /// 机器人子弹对象池
    /// </summary>
    public Queue<Transform> AndroidBulletPool = new Queue<Transform>();

    /// <summary>
    /// 机器人对象池
    /// </summary>
    public List<Transform> AndroidPool = new List<Transform>();

    /// <summary>
    /// 子弹飞行时间
    /// </summary>
    private float bulletAwakeTime = 3f;
    public float GetBulletAwakeTime()
    {
        return bulletAwakeTime;
    }
    /// <summary>
    /// 玩家子弹tag
    /// </summary>
    public string bullet_tag_player = "bullet_player";
    /// <summary>
    /// 机器人子弹tag
    /// </summary>
    public string bullet_tag_android = "bullet_android";

    /// <summary>
    /// 玩家攻击力
    /// </summary>
    private float player_force = 1;

    public float GetPlayerForce()
    {
        return player_force;
    }
    public void SetPlayerForce(float value)
    {
        player_force = value;
    }

    /// <summary>
    /// 玩家总血量
    /// </summary>
    private float player_full_blood = 0;
    public float GetPlayerFullBlood()
    {
        return player_full_blood;
    }
    public void SetPlayerFullBlood(float value)
    {
        player_full_blood = value;
    }

    /// <summary>
    /// 机器人总数
    /// </summary>
    private int androidCount = 0;
    public int GetAndroidCount()
    {
        return androidCount;
    }
    public void SetAndroidCount(int count)
    {
        androidCount = count;
    }

}
